package org.myorg.v4;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.Writable;
import org.myorg.v6.MountainRecordWritable;


public class FPeopleWritable4 extends FPeople4 implements Writable {
	
	public FPeopleWritable4() {
		super();
	}
	
	public FPeopleWritable4(int num, int length) {
		super(num, length);
	}
	

	public FPeopleWritable4(FPeople4 people) {
		super(people);
	}
	
	@Override
	public void write(DataOutput out) throws IOException {
		// TODO Auto-generated method stub
		out.writeLong(it);
		out.writeInt(p_num);
		for (int i = 0; i < p_num; i++ ) {
			FGeneWritable4 p = new FGeneWritable4(persons[i]);
			p.write(out);
		}
		MountainRecordWritable wrec = new  MountainRecordWritable(rec);
		wrec.write(out);
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		// TODO Auto-generated method stub
		it = in.readLong();
		p_num = in.readInt();
		persons = new FGene4[p_num];
		
		for (int i = 0; i < p_num; i++ ) {
			FGeneWritable4 p = new FGeneWritable4();
			p.readFields(in);
			persons[i] = p;
		}
		MountainRecordWritable rrec = new  MountainRecordWritable();
		rrec.readFields(in);
		rec = rrec;
	}

}
